package linkwechat.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@Builder
@NoArgsConstructor

// 响应结果
public class ReturnData {
    private Integer code;   // 状态码
    private String msg;     // 描述信息
    private Object data;    // 数据

    //    请求成功
    public static ReturnData respSuccess(Object data){
        return ReturnData.builder().code(ReturnEnum.QUERY_SUCCEED.getCode()).msg(ReturnEnum.QUERY_SUCCEED.getMsg()).data(data).build();
    }

    //    请求失败
    public static ReturnData respError(){
        return ReturnData.builder().code(ReturnEnum.ERROR.getCode()).msg(ReturnEnum.ERROR.getMsg()).build();
    }


    public static ReturnData setResp(ReturnEnum returnEnum,Object data){
        return ReturnData.builder().code(returnEnum.getCode()).msg(returnEnum.getMsg()).data(data).build();
    }
}
